<?php
/*
Bitsand - a web-based booking system for LRP events
Copyright (C) 2006 - 2008 The Bitsand Project (http://bitsand.googlecode.com/)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

include ('../inc/inc_head_db.php');
include ('../inc/inc_admin.php');
include ('../inc/inc_head_html.php');

//Get list of players
$db_prefix = DB_PREFIX;
$sql = "SELECT plPlayerID, " .
	"plFirstName, " .
	"plSurname, " .
	"plBookAs, " .
	"chName, " .
	"bkDateOOCConfirmed, " .
	"bkDateICConfirmed, " .
	"bkDatePaymentConfirmed, " .
	"UNIX_TIMESTAMP(bkDateOOCConfirmed) + UNIX_TIMESTAMP(bkDateICConfirmed) AS dDateSort " .
	"FROM {$db_prefix}players, {$db_prefix}characters, {$db_prefix}bookings " .
	"WHERE plPlayerID = chPlayerID AND chPlayerID = bkPlayerID";
$result = ba_db_query ($link, $sql);
?>
<script src="../inc/sorttable.js" type="text/javascript"></script>

<h1><?php echo TITLE?> - Bookings Status</h1>

<p>
<a href = 'admin.php'>Admin</a>
</p>

<p>
Click on a column header to sort by that column.
</p>

<table border = '1' class="sortable">
<tr>
<th>Player ID</th>
<th>OOC Name</th>
<th>IC Name</th>
<th>Details Confirmed?</th>
<th>Paid?</th>
<th>Booking As</th>
</tr>

<?php
while ($row = ba_db_fetch_assoc ($result)) {
	echo "<tr class = 'highlight'>\n<td>";
	echo PID_PREFIX . sprintf ('%03s', $row ['plPlayerID']) . "</td>\n";
	echo "<td>" . htmlentities (stripslashes ($row ['plFirstName'])) . " " . htmlentities (stripslashes ($row ['plSurname']));
	echo "</td><td>\n";
	echo htmlentities (stripslashes ($row ['chName']));
	echo "</td>\n";
	$sConfirm = '';
	if ($row ['bkDateOOCConfirmed'] != '0000-00-00' && $row ['bkDateOOCConfirmed'] != '')
		$sConfirm = "OOC";
	if ($row ['bkDateICConfirmed'] != '0000-00-00' && $row ['bkDateICConfirmed'] != '') {
		if ($sConfirm == "OOC")
			$sConfirm = "OOC &amp; ";
		$sConfirm .= "IC";
	}
	if ($sConfirm != '')
		$sConfirm .= " details confirmed";
	if ($sConfirm == 'OOC &amp; IC details confirmed')
		$sConfirm = "<span class = 'sans-green'>$sConfirm</span>";
	echo "<td>$sConfirm</td>\n";
	if ($row ['bkDatePaymentConfirmed'] != '0000-00-00' && $row ['bkDatePaymentConfirmed'] != '')
		echo "<td><span class = 'sans-green'>Paid</span></td>\n";
	else
		echo "<td><span class = 'sans-warn'>Not paid</span></td>\n";
	echo "<td>" . htmlentities (stripslashes ($row ['plBookAs']));
	echo "</td>\n</tr>";
}
?>

</table>

<?php
include ('../inc/inc_foot.php');
?>
